package core

import "github.com/bwmarrin/snowflake"

var (
	Epoch  int64 = 1521556702000
	GFlake *Flake
)

type Flake struct {
	Node  *snowflake.Node
	Epoch int64
}

func NewSnowFlake(nodeId int64) (flake Flake, err error) {
	snowflake.Epoch = Epoch
	node, err := snowflake.NewNode(nodeId)
	if err != nil {
		return
	}
	flake.Node = node
	GFlake = &flake
	return
}
func (obj Flake) GetId() (id int64) {

	id = obj.Node.Generate().Int64()
	return
}
